package com.longrise.android.byjk.plugins.tabthird.personal;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.webkit.WebView;
import android.widget.RelativeLayout;

import com.longrise.android.byjk.R;
import com.longrise.android.byjk.plugins.aboutme.personalInfo.PersonalInfoActivity;
import com.longrise.android.byjk.utils.GetWebUrlHelper;
import com.longrise.common.base.web.BaseWebActivity;
import com.longrise.common.base.web.BaseWebBridge;
import com.longrise.common.base.web.BaseWebClient;
import com.longrise.common.utils.NetUtil;
import com.longrise.common.utils.PrintLog;

/**
 * Created by callxkj on 2017/11/8.
 * 展业秀  个人主页
 */

public class PersonalShowActivity extends BaseWebActivity implements View.OnClickListener {

    private WebView mWv;
    private RelativeLayout back_zy;
    private final int STARTA_EDIT_REQUEST = 102;

    @Override
    public int getContentViewId(@Nullable Bundle savedInstanceState) {
        return R.layout.web_person_show;
    }

    @Override
    public WebView getWebView() {
        return mWv;
    }

    @Override
    public void init() {
        mWv = (WebView) findViewById(R.id.comment_wv);
        back_zy = (RelativeLayout) findViewById(R.id.back_zy);
        setToolbarVisible(false);
        back_zy.setOnClickListener(this);
    }

    @Override
    public void initData() {
        request();
    }

    public void request(){
        GetWebUrlHelper.getWebUrl(GetWebUrlHelper.GRZY, new GetWebUrlHelper.OnGetWebUrlResultListener() {
            @Override
            public void onSuccess(String url) {
                loadUrl(url);
            }

            @Override
            public void onError(String errormsg) {
                showToast(errormsg);
            }
        });
    }

    @Override
    public BaseWebBridge getwebBridge() {
        return new PersonShowBridge(this, mRxmanager);
    }

    @Override
    public BaseWebClient getWebClient() {
        return null;
    }

    public void startActivity(){
        Intent intent = new Intent(PersonalShowActivity.this, PersonalInfoActivity.class);
        startActivityForResult(intent, STARTA_EDIT_REQUEST);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == STARTA_EDIT_REQUEST) {
            PrintLog.e("PersonShow","111111111111");
            if (NetUtil.checkNetEnable()) {
                request();
                PrintLog.e("PersonShow","2222222222");
            }
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back_zy:
                finish();
                break;
        }
    }

}
